<!DOCTYPE html>
<html xmlns:v="urn:schemas-microsoft-com:vml"
      xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:w="urn:schemas-microsoft-com:office:word"
      xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
      xmlns="http://www.w3.org/TR/REC-html40">

<head>
    <meta charset="utf-8">
    <title>党员登记系统     </title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <style>
        body html {
            padding: 0px;
            height: auto;
        }

        .hand {
            cursor: pointer;
        }

        .btnactive {
            background: #5E5E5E;
            color: #FFFFFF;
        }

        .ml {
            margin-left: 10px;
        }

        .hide {
            display: none;
        }

        .trbtn {
            padding-top: 0px;
            padding-bottom: 0px;
        }

        .navli {
            padding-left: 0px;
            padding-right: 0px;
        }

        .leftnav-inverse {
            position: fixed;
            padding-left: 0px;
            padding-right: 0px;
            height: auto;
            overflow: auto;
            top: 50px;
            bottom: 0px;
            background: #222222;
        }

        .leftnav-default {
            position: fixed;
            padding-left: 0px;
            padding-right: 0px;
            height: auto;
            overflow: auto;
            background: #f8f8f8;
            top: 50px;
            bottom: 0px;
        }

        .noleftpadding {
            padding-left: 0px;
        }

        .tddetail {
            width: 100px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
</head>

<body>
<iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe>
<nav id="nav" class="nav navbar-inverse navbar-fixed-top" style="" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a href="#" class="navbar-brand">
                <span class="glyphicon glyphicon-book"></span>
                <strong>党员登记系统</strong>
            </a>
        </div>
        <div class="navbar-form">
            <div class="form-group">
                <!--<div class="btn btn-info" name="themname" onclick="changethethem()">更换浅色调主题-->
                <!--</div>-->
            </div>
            <div class="navbar-form pull-right">
                <div class="form-group" style="padding-left: 10px;margin: 0px 12px;">
                    <a href="#" class="navbar-link" onclick="loginout()">注销</a>
                    <span class="navbar-link" style="padding-left: 5px;">|</span>
                    <a class="navbar-link" style="padding-left: 5px;" onclick="safeloginout()">安全退出</a>
                </div>
            </div>
        </div>
    </div>
</nav>
<div style="height:50px;"></div>
<div class="container-fluid noleftpadding">
    <div id="leftnavback" class="leftnav-inverse col-md-2">
        <ul id="navonleft" class="nav navbar-nav navbar-inverse" style="width: 100%;">
            <li class="col-md-12 navli" onclick="show_lable('student_list');get_student_list();">
                <a href="#">
                    <i class="glyphicon glyphicon-th-large"></i> 查看当前成员
                </a>
            </li>
            <li class="col-md-12 navli" onclick="show_lable('student_add');">
                <a href="#">
                    <i class="glyphicon glyphicon-th-large"></i> 添加成员
                </a>
            </li>
            <li class="col-md-12 navli" style="display: none;" id="admin_op1" onclick="show_lable('admin_add');">
                <a href="#">
                    <i class="glyphicon glyphicon-th-large"></i> 添加管理员
                </a>
            </li>
            <li class="col-md-12 navli" style="display: none;" id="admin_op3" onclick="show_lable('department_list');get_department_list();">
                <a href="#">
                    <i class="glyphicon glyphicon-th-large"></i> 查看党支部
                </a>
            </li>
            <li class="col-md-12 navli" style="display: none;" id="admin_op2" onclick="show_lable('department_add');">
                <a href="#">
                    <i class="glyphicon glyphicon-th-large"></i> 添加党支部
                </a>
            </li>
        </ul>
    </div>

    <div id="body" class="col-md-10 col-md-offset-2" style="padding: 40px;height: 100%;overflow: auto;">
        <div id="student_list" style="display: none;">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>姓名</th>
                    <th>学号</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="student_list_body">
                <tr class="active">
                    <!--<td>201607050001</td>-->
                    <!--<td>张中昊</td>-->
                    <!--<td>13631215702</td>-->
                    <!--<td><a href="javascript:get_student_info('04140329');">查看信息</a></td>-->
                </tr>
                </tbody>
            </table>
        </div>
        <div id="department_list" style="display: none;">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>党支部名称</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="department_list_body">
                <tr class="active">
                    <!--<td>201607050001</td>-->
                    <!--<td>张中昊</td>-->
                    <!--<td>13631215702</td>-->
                    <!--<td><a href="javascript:get_student_info('04140329');">查看信息</a></td>-->
                </tr>
                </tbody>
            </table>
        </div>
        <div id="student_info" style="display: none;width: 100%; padding-left: 15%; padding-right: 15%;">

        </div>
        <div id="student_add" style="display: none;">
            <form class="form-horizontal"
                  action="http://jluzh.ningmeng6.com/dygl/index.php/Home/index/add_student" method="post"
                  target="nm_iframe">
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">学号：</label>
                    <div class="col-md-6">
                        <input name="study_number" type="text" placeholder="学号" class="form-control">
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">姓名：</label>
                    <div class="col-md-6">
                        <input type="text" name="name" placeholder="姓名" class="form-control">
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">学院：</label>
                    <div class="col-md-6">
                        <input type="text" name="department" placeholder="学院" class="form-control" readonly>
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">&nbsp;</label>
                    <div class="controls col-md-4">
                        <input class="btn btn-block btn-info" value="确认添加" type="submit"/>
                    </div>
                </div>
            </form>
        </div>
        <div id="admin_add" style="display: none;">
            <form class="form-horizontal"
                  action="" method="post"
                  target="nm_iframe">
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">姓名(拼音)：</label>
                    <div class="col-md-6">
                        <input type="text" name="admin_uname" placeholder="姓名" class="form-control">
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">密码：</label>
                    <div class="col-md-6">
                        <input name="admin_pwd" type="text" placeholder="密码" class="form-control">
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">党支部：</label>
                    <div class="col-md-6">
                        <!--<input type="text" name="department" placeholder="学院" class="form-control">-->
                        <select class="form-control" name="admin_department" id="admin_add_department">
                            <option value="">--请选择总党支--</option>
                        </select>
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">&nbsp;</label>
                    <div class="controls col-md-4">
                        <div class="form-control btn btn-circle btn-info" onclick="add_admin();"> 添加</div>
                    </div>
                </div>
            </form>
        </div>
        <div id="department_add" style="display: none;">
            <form class="form-horizontal"
                  action="" method="post"
                  target="nm_iframe">
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">党支部名称：</label>
                    <div class="col-md-6">
                        <input type="text" name="add_departmrnt" placeholder="党支部名称" class="form-control">
                        <p class="help-block">必填</p>
                    </div>
                </div>
                <div class="control-group col-md-12">
                    <label class="control-label col-md-2">&nbsp;</label>
                    <div class="controls col-md-4">
                        <div class="form-control btn btn-circle btn-info" onclick="add_department();"> 添加</div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="./js/user.js"></script>
<script type="text/javascript" src="./js/common_var.js"></script>
<script type="text/javascript" src="./js/mustache.js"></script>
<script type="text/javascript" src="./js/jquery.cookie.js"></script>
<script type="text/javascript" src="./js/jquery-barcode.min.js"></script>
<script type="text/javascript" src="./js/jquery.jqprint-0.3.js"></script>
<script type="text/javascript" src="./FileSaver.js"></script>
<script type="text/javascript" src="./jquery.wordexport.js"></script>
<script type="text/javascript" src="./js/jquery.cookie.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script src="https://cdn.bootcss.com/moment.js/2.18.1/moment-with-locales.min.js"></script>
<link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css"
      rel="stylesheet">
<script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<script>
    var time_picker_array = ['yanshi1', 'yanshi2', 'zhuanzhenggongzhengshijian2', 'yubeiqikaochashijian2',
        'yubeidangyuangongshishijian2', 'shenqingshijian', 'tanhuashijian', 'shenqingrudanggongshishijian',
        'qimengjiaoyushijian', 'tuanzhibushujuqianziriqi', 'jijifenzihuiyishijian', 'jijifenzigongshishijian',
        'jijifenziquedingshijian', 'jijifenzibeianshijian', 'jijifenzishiquedingshijian', 'jijifenzishieiyangdengjishijian',
        'dangxiaoeixunshijian', 'fanzhanduixianghuiyishijian', 'dangshibubeianshijian', 'dangzhibufuzerenqianzishijian',
        'zhengshengongshishijian', 'yubeidangyuangongshishijian1', 'rudangzhiyuanshushijian', 'yubeidanhyudahuishijian',
        'dangzhibufuzerenqianzishijain2', 'yanjiushijian', 'kaochadengjishijian', 'xuanshishijian', 'yubeiqikaocashijian1',
        'gerenzhuanzhengshijian', 'zhuanzhenggongzhengshijian1', 'zhuanzhenghuiyishijian', 'dangzhibufuzerenqianzishijian3',
        'yanjiujuedingshijian', 'yanshizhuanzhengshijian','chushengnianyue'];

    if ($.cookie('id') != null && $.cookie('type') != null) {
        if ($.cookie('type') == 1) {
            $("#admin_op1").fadeIn();
            $("#admin_op2").fadeIn();
            $("#admin_op3").fadeIn();
        }
        $('[name="department"]').val($.cookie('department'));
        get_student_list();
        show_lable('student_list');
    } else {
        window.location.href = "login.html";
    }

    function test() {
        var input_list = $('#word_info input');
        $(input_list).each(function (index, element) {
            console.log($(element).val());
            $(element).parent('label').empty().html($(element).val());
        })
        $("#word_info").wordExport($("#study_number1").val() + '_发展党员全程纪实表');
    }

    // $(
    //     function() {
    //         if($.cookie('USERID') != null && $.cookie('TOKEN') != null) {
    //             openaddfile();
    //         } else {
    //             window.location.href = "login.html";
    //         }
    //     }
    // );

    function loginout() {
        $.cookie('id', '', {
            expires: -1
        });
        $.cookie('type', '', {
            expires: -1
        });
        $.cookie("department", "", {
            expires: -1
        });
        window.location.href = "login.html";
    }

    function get_student_info(study_number) {
        var ajaxdata;
        ajaxdata = {
            study_number: study_number,
        };
        $.ajax({
            type: "post",
            url: "http://jluzh.ningmeng6.com/dygl/front/module/student_info.html",
            async: false,
            data: ajaxdata,
            datatype: "json",
            success: function (ret) {
                $("#student_info").html(ret);
                $.ajax({
                    type: "post",
                    url: "" + host + "Home/index/get_student_info",
                    async: true,
                    data: ajaxdata,
                    datatype: "json",
                    success: function (ret) {
                        var input_list = $('#word_info input');
                        $(input_list).each(function (index, element) {
                            $(element).parent('label').css("width", $(element).css('width'));
                            $(element).parent('label').css("padding", 0);
                            $(element).parent('label').css("margin", 0);
                            $(element).css("width", "100%");
                        })
                        $("#study_number1").val(study_number);
                        ret = eval('(' + ret + ')');
                        for (var i = 0; i < (ret['result']).length; i++) {
                            $('[name="' + ret['result'][i]['key'] + '"]').val(ret['result'][i]['value']);
                        }
                        // $("#student_info").fadeIn();
                        show_lable('student_info');
                        for (time_picker in time_picker_array) {
                            $('[name="' + time_picker_array[time_picker] + '"]').datetimepicker({
                                format: 'YYYY-MM-DD',
                                locale: moment.locale('zh-cn')
                            });
                        }

                    }
                });
            }
        });
    }


    get_department();

    function get_department() {
        $.ajax({
            type: "post",
            url: "" + host + "Home/index/get_department_list",
            async: true,
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                console.log(ret);
                html = "";
                for (var i = 0; i < (ret['result']).length; i++) {
                    html += '<option value="' + ret['result'][i]['department'] + '">' + ret['result'][i]['department'] + '</option>';
                }
                $("#admin_add_department").html($("#admin_add_department").html() + html);
            }
        });
    }

    function add_admin() {
        $.ajax({
            type: "post",
            url: "" + host + "Home/index/add_admin",
            async: true,
            data: {
                uname : $("[name='admin_uname']").val(),
                pwd : $("[name='admin_pwd']").val(),
                department:$("[name=admin_department]").val()
            },
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                console.log(ret);
                alert(ret['msg']);
            }
        });
    }
    function add_department() {
        $.ajax({
            type: "post",
            url: "" + host + "Home/index/add_department",
            async: true,
            data: {
                department:$("[name=add_departmrnt]").val()
            },
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                console.log(ret);
                alert(ret['msg']);
            }
        });
    }

    function get_student_list() {
        var ajaxdata;
        ajaxdata = {
            department: $.cookie('department')
        };

        $.ajax({
            type: "post",
            url: "" + host + "Home/index/get_student_list",
            async: true,
            data: ajaxdata,
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                console.log(ret);
                html = "";
                for (var i = 0; i < (ret['result']).length; i++) {
                    html += '<tr class="active">';
                    html += '<td>' + ret['result'][i]['id'] + '</td>';
                    html += '<td>' + ret['result'][i]['name'] + '</td>';
                    html += '<td>' + ret['result'][i]['study_number'] + '</td>';
                    html += '<td><a href="javascript:get_student_info(' + "'" + ret['result'][i]['study_number'] + "'" + ');">查看信息</a></td>';
                    html += '</tr>'
                }
                $("#student_list_body").html(html);
            }
        });
    }

    function get_department_list() {
        // var ajaxdata;
        // ajaxdata = {
        //     department: $.cookie('department')
        // };

        $.ajax({
            type: "post",
            url: "" + host + "Home/index/get_department_list",
            async: true,
            // data: ajaxdata,
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                console.log(ret);
                html = "";
                for (var i = 0; i < (ret['result']).length; i++) {
                    html += '<tr class="active">';
                    html += '<td>' + ret['result'][i]['id'] + '</td>';
                    html += '<td>' + ret['result'][i]['department'] + '</td>';
                    html += '<td><a href="javascript:del_department(' + "'" + ret['result'][i]['id'] + "'" + ');">删除</a></td>';
                    html += '</tr>'
                }
                $("#department_list_body").html(html);
            }
        });
    }

    function del_department(id) {
        $.ajax({
            type: "post",
            url: "" + host + "Home/index/del_department",
            async: true,
            data: {
                id : id
            },
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                get_department_list();
                alert(ret['msg']);
            }
        });
    }

    function show_lable(id) {
        $('#body > div').hide();
        $("#" + id).show();
    }
</script>
</html>